<?php if(!empty($report)){?>
<style>
.info_table{
	border-collapse:collapse;
	font-size:12px;
	text-align:center;
}
.info_table tr th{
	border:1.5px solid;
}
.info_table tr.per_list td{
	border:1px solid;
}
.excle_title{
	border:0px;
	text-align:center;
}
.info_table tr.per_list td.ltd{
	border-left:1.5px solid;
}
.info_table tr.per_list td.rtd{
	border-right:1.5px solid;
}
.info_table tr.per_list td.btd{
	border-bottom:1.5px solid;
}
.info_table tr.per_list td.normal_td{
	border:1px solid;
}
</style>
<?php }?>
<?php if(empty($report)){?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2>企业其它需求信息汇总</h2>
	</div>
	<?php  
		if($showpage == 1) {
			if(isset($paging)){ echo $this->renderElement('pagination',$paging);} 
		}
    	echo '<div class="right back_btn">';
		echo $html->link("生成文件","javascript:void(0)",array("onclick"=>"generate()"));
		echo '</div>';
	?>
    <div class="right search_box">
		<form onsubmit="return searchtech()">
	    	<div class="left search_text">
	    		<?php echo $form->text('company.keyword',array('placeholder'=>'查询标题','value'=>$publishtitle, 
	    													   'id'=>'search', 'class'=>'text_box'));?>
	    	</div>
	    	<div class="left right_side_title">
			<?php 
					 $user=$session->read('User');
					 if($user['isadmin']||$user['isvisitor']){
						$grouplist=array_merge(array(""=>"请选择模块"),$grouplist);
				    	echo $form->select('ddlgroup',$grouplist,$group_mod_id, null,null);
					 }
			?>
			</div>
	        <div class="left search_btn"><input type="submit" value=""/></div>
        </form>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <div class="items_list">
<?php }?>
        	<table class="info_table">
        	<?php 
        		if(!empty($report)){
        			echo "<tr ><td class='excle_title' colspan='7'><h3>企业需求信息汇总（其它需求）</h3></td></tr>";
        		}
        	?>
            	<tr>
                    <th>企业名称</th>
                    <th>模块</th>
                    <th>标题</th>
                    <th>需求类型</th>
     				<th>需求描述</th>
     				<th>发布人</th>
     				<th>发布时间</th>
     				<th>有效期(天)</th>
                </tr>
                <?php 
                if($companys){
                	$index = 0;
                	$countcom = count($companys);
					foreach($companys as $company){
						$index++;
						$id = $company["SearchCompany"]["id"];
						$company_name = $company["SearchCompany"]["company_name"];
						$showcname = $company_name;
						$groupname = $grouplist[$company["SearchCompany"]["groupid"]];
						
						if(!empty($report)){
							$showcname = $company_name;
						}else{
							$showcname = $html->link($str->sub_len($showcname,20),"/companys/showinfosummary/".$id,array("title"=>$company_name),null);
						}			
						$objdemands = $company["CompDemand"];
						$objdemandcount = count($objdemands);
						$i=0;
						$btd = "";
						if($countcom == $index){
							$btd = "btd";
						}
						if(!empty($objdemands)){
							foreach($objdemands as $objdemand){
								$demandid = $objdemand["id"];
								$title = $objdemand["title"];
								$need = $objdemand["need"];
								$require_type = $objdemand["require_type"];
								echo "<tr class='per_list'>";
								if($i == 0){
									echo "<td class='ltd ".$btd."' rowspan='".$objdemandcount."'>".$showcname."</td>";
								}
								echo "<td>".$groupname."</td>";
								if(!empty($report)){
									echo "<td class='".$btd."'>".$title."</td>";
								}else{
     								echo "<td>".$html->link($str->sub_len($title,10),"/companys/showdemand/".$demandid,null)."</td>";
								}
								foreach($type as $key=>$rtype){
		                		   if($key==$require_type){
		                		   		echo "<td class='".$btd."'>".$rtype."</td>";break;
		                			}
								}
     							if(!empty($report)){
     								echo "<td class='".$btd."'>".$need."</td>";
     							}else{
     								echo "<td title=".$need.">".$str->sub_len($need,15)."</td>";
     							}
     							echo "<td class='".$btd."'>".$objdemand["publisher"]."</td>";  		 						
        		                echo "<td class='".$btd."'>".date("Y-m-d",strtotime($objdemand["created"]))."</td>";
        		                echo "<td class='rtd ".$btd."'>".$objdemand["validity"]."</td>";    
								echo "</tr>";
								$i++;
							}
							
						}
						if($i==0){
							echo "<tr class='per_list'>";
							echo "<td class='ltd ".$btd."'>".$showcname."</td>";
							echo "<td class='normal_td ".$btd."'></td><td class='normal_td ".$btd."'></td>
								  <td class='normal_td ".$btd."'></td><td class='normal_td ".$btd."'></td>
								  <td class='normal_td ".$btd."'></td><td class='rtd ".$btd."'></td>";
							echo "</tr>";
						}
					}
				}?>
            </table>
<?php if(empty($report)){?>
		</div>
    </div>
</div>
<script>
$(document).ready(function() {
	$("#ddlgroup").change(function(){
		searchtech();
		});

});
if($("#search").val()!=""){
	$("#search").focus();
}
function searchtech()
{	
	var webpath=$("#getpath").attr('href');
	var urlpath=webpath+"searchs/publishdemand?seach=all";
	var search=$("#search").val();
	var group=$("#ddlgroup").val();	
	if(group==""&&search==""){
		location.href=urlpath;
	}else{
		if(group!=""){
			urlpath+="&group="+group;
			}
		if(search.trim()!=""){
			urlpath+="&publishtitle="+search.trim();
		}
		location.href=urlpath;
	}
	return false;
}
function generate(){
	var str1=new Array();
	var str2=new Array();
	var url_before=window.location.href;
	str1=url_before.split('searchs/');
	str2=str1[1].split('?');
	
	publishtitle = $("#search").val();
	location.href=webpath+"searchs/publishdemand/1?publishtitle="+publishtitle+"&"+str2[1];
}
funPlaceholder(document.getElementById("search"));
</script>
<?php }?>